import { IParam, EntityBase } from '@/core';
import { IAuth_granted_role } from './interface/i-auth-granted-role';
import Auth_granted_roleKeys from './auth-granted-role-keys';

/**
 * 授权角色基类
 * 基于template/src/api/{{appEntities}}/{{appEntities}}-base.ts.hbs生成
 *
 * @export
 * @abstract
 * @class Auth_granted_roleBase
 * @extends { EntityBase }
 * @implements { IAuth_granted_role }
 */
export abstract class Auth_granted_roleBase
	extends EntityBase
	implements IAuth_granted_role
{
	/**
	 * 实体名称
	 *
	 * @readonly
	 * @type {string}
	 * @memberof Auth_granted_roleBase
	 */
	get srfdename(): string {
		return 'AUTH_GRANTED_ROLE';
	}

	/**
	 * 当前实体所有属性
	 *
	 * @protected
	 * @type {string[]}
	 * @memberof Auth_granted_roleBase
	 */
	protected get keys(): string[] {
		return Auth_granted_roleKeys;
	}

	/**
	 * Creates an instance of ConstactOppoBase.
	 * @param {*} [data]
	 * @memberof Auth_granted_roleBase
	 */
	constructor(data?: any) {
		super();
		this.setData(data);
	}

	get srfkey(): string {
		return this.role_id;
	}

	set srfkey(val: string) {
		this.role_id = val;
	}

	/**
	 * 角色标识
	 **/
	role_id?: any;

	get srfmajortext(): string {
		return this.display_name;
	}

	set srfmajortext(val: string) {
		this.display_name = val;
	}
	/**
	 * 角色名
	 **/
	display_name?: any;

	/**
	 * 角色代码标记
	 **/
	authority?: any;

	/**
	 * 授权清单
	 **/
	authorities?: any;

	/**
	 * 重置实体数据
	 *
	 * @param {IParam} [data={}]
	 * @memberof Auth_granted_roleBase
	 */
	reset(data: IParam = {}): void {
		super.reset(data);
		this.role_id = data.role_id || data.srfkey;
		this.display_name = data.display_name || data.srfmajortext;
	}
}
